<?php

/* ::: POINTS CLASS ::: */
/* Calculates userpoints on different actions */

class points
{
    private $winPoints;
    private $losePoints;
    private $startPoints;


    /**
     * points::__construct()
     * 
     * @param mixed $args
     * @return null
     */
    function __construct( array $args )
    {
        foreach ( $args as $att => $val )
        {
            if ( is_null( $this->$att ) )
            {
                $this->$att = $val;
            }
        }
    }

    /**
     * points::winner()
     * 
     * Calculates points for winner
     * @param mixed $points
     * @return int
     */
    function winner( int $points )
    {
        $calc = $points + $this->winPoints;
        return ( int )$calc;
    }

    /**
     * points::looser()
     * 
     * Calculate points for looser
     * @param mixed $points
     * @return int
     */
    function looser( int $points )
    {
        $calc = $points - $this->losePoints;
        return ( int )$calc;
    }

    /**
     * points::init()
     * 
     * Calculate points when user is created
     * @param mixed $points
     * @return int
     */
    function init( int $points )
    {
        return ( int )$this->startPoints;
    }
}
